package com.woniu.shop.controller;


import com.woniu.entity.PageResult;
import com.woniu.entity.Result;
import com.woniu.entity.ResultCode;
import com.woniu.shop.entity.dto.ShopApplyDTO;
import com.woniu.shop.pojo.ShopApply;
import com.woniu.shop.service.IShopApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.woniu.entity.PageResult;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;

/**
 * <p>
 * 门店申请表 前端控制器
 * </p>
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/shop-apply")
@Api(tags = "门店申请控制类")
public class ShopApplyController {

    @Autowired
    private IShopApplyService shopApplyService;

    @PostMapping("/apply")
    @ApiOperation("门店申请")
    public Result<Object> apply(@RequestBody ShopApplyDTO shopApplyDTO){
        return shopApplyService.apply(shopApplyDTO);
    }


    //查询门店审核信息
    @ApiOperation("查询门店审核信息")
    @PostMapping("/checkRegistrationInfo/{currentPage}/{pageSize}")
    public Result<PageResult<ShopApply>> checkRegistrationInfo(String shopName, @PathVariable Integer currentPage, @PathVariable Integer pageSize){
        PageResult<ShopApply> pageResult = shopApplyService.checkRegistrationInfo(shopName,currentPage,pageSize);
        return Result.ok(ResultCode.SUCCESS.getCode(), "查询成功！",pageResult);
    }

    //门店注册信息审核
    @ApiOperation("门店注册信息审核")
    @GetMapping("/registrationAndReview/{id}")
    public Result registrationAndReview(@PathVariable String id) throws ExecutionException, InterruptedException {
        shopApplyService.registrationAndReview(id);
        return Result.ok();
    }
}
